﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace test12
{
    public partial class Form2 : Form
    {
        OrderService os;
        String goodsName;
        int goodsPrice;
        String CName;
        String CWork;
        int moneyNum;
        int orderNum;
        int t;//判断是修改还是新建订单
        public Form2(OrderService os,int t)
        {
            InitializeComponent();
            this.os = os;
            this.t = t;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Order od = new Order(orderNum, goodsName, CName,CWork, moneyNum);
            if(t==1)os.AddOrder(od);
            if (t == 2) os.UpdateOrder(od);
            Close();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            this.goodsName = textBox1.Text;
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            this.goodsPrice = int.Parse(textBox2.Text);
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            this.CName = textBox3.Text;
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {
            this.CWork = textBox4.Text;
        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {
            this.orderNum = int.Parse(textBox5.Text);
        }

        private void textBox6_TextChanged(object sender, EventArgs e)
        {
            this.moneyNum = int.Parse(textBox6.Text) * goodsPrice;
        }
    }
}
